package com.ihisun.tmhcms.controller.giftbagcontroller;

import com.ihisun.tmhcms.core.dto.editgiftbag.EditVipPackageDto;
import com.ihisun.tmhcms.core.dto.editgiftbag.SearchGiftBagDto;
import com.ihisun.tmhcms.core.dto.editgiftbag.VipPackageMechanismDto;
import com.ihisun.tmhcms.core.service.giftbagservice.GiftBagService;
import com.ihisun.tmhcms.core.vo.MechanismVo;
import com.ihisun.tmhcms.core.vo.VipPackageVo;
import com.ihisun.tmhcms.utils.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "礼包相关Api")
@RestController
@RequestMapping("/giftbag")
public class GiftBagController {
    @Resource
    GiftBagService giftBagService;

    @PostMapping("/editGiftBag")
    @ApiOperation("编辑礼包")
    public ResponseVo editGiftBag(@RequestBody EditVipPackageDto editVipPackageDto) {
        return giftBagService.editGiftBag(editVipPackageDto);
    }

    @PostMapping("/searchGiftBag")
    @ApiOperation(value = "礼包列表", response = VipPackageVo.class)
    public ResponseVo searchGiftBag(@RequestBody SearchGiftBagDto searchGiftBagDto) {
        return giftBagService.searchGiftBag(searchGiftBagDto);
    }

    @GetMapping("/updateState")
    @ApiOperation(value = "修改礼包状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "packageId", value = "礼包Id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "状态  1正常   2下架   3删除", dataType = "String", paramType = "query")
    })
    public ResponseVo updateState(String packageId, String state) {
        return giftBagService.updateState(packageId, state);
    }

    @GetMapping("/packageInfo")
    @ApiOperation(value = "礼包详情", response = VipPackageVo.class)
    @ApiImplicitParam(name = "packageId", value = "礼包Id", dataType = "String", paramType = "query")
    public ResponseVo packageInfo(String packageId) {

        return giftBagService.packageInfo(packageId);
    }


    @GetMapping("/findByMechanism")
    @ApiOperation(value = "机构列表", response = MechanismVo.class)
    public ResponseVo findByMechanism() {
        return giftBagService.findByMechanism();
    }

    @GetMapping(value = "/findByPackageMechanisnm")
    @ApiOperation(value = "查询已经关联的机构", response = VipPackageMechanismDto.class)
    @ApiImplicitParam(name = "packageId", value = "礼包Id", dataType = "String", paramType = "query")
    public ResponseVo findByPackageMechanisnm(String packageId) {
        return giftBagService.findByPackageMechanisnm(packageId);
    }

    @GetMapping(value = "/findByPackageCity")
    @ApiOperation(value = "查询已经关联城市", response = VipPackageMechanismDto.class)
    @ApiImplicitParam(name = "packageId", value = "礼包Id", dataType = "String", paramType = "query")
    public ResponseVo findByPackageCity(String packageId) {
        return giftBagService.findByPackageCity(packageId);
    }



}
